<script setup lang="ts" name="Profile">
import { ProfileApi, ProfileType } from '@/api/system/user/profile'
import { BasicInfo, ProfileUser, ResetPassword, UserSocial } from './components'

const { t } = useI18n()
const activeName = ref('basicInfo')

const userInfo = ref({} as ProfileType)
const getUserInfo = async () => {
  userInfo.value = await ProfileApi.detail()
}

onMounted(async () => {
  await getUserInfo()
})
</script>

<template>
  <PageCard direction="row">
    <el-card class="user w-1/3" shadow="hover">
      <template #header>
        <div class="card-header">
          <span>{{ t('profile.user', 'title') }}</span>
        </div>
      </template>
      <ProfileUser :userInfo="userInfo" />
    </el-card>
    <el-card class="user ml-20px w-2/3" shadow="hover">
      <template #header>
        <div class="card-header">
          <span>{{ t('profile.info', 'title') }}</span>
        </div>
      </template>
      <div>
        <el-tabs v-model="activeName" class="profile-tabs" style="height: 400px" tab-position="top">
          <el-tab-pane :label="t('profile.info', 'basicInfo')" name="basicInfo">
            <BasicInfo :userInfo="userInfo" />
          </el-tab-pane>
          <el-tab-pane :label="t('profile.info', 'resetPwd')" name="resetPwd">
            <ResetPassword />
          </el-tab-pane>
          <el-tab-pane :label="t('profile.info', 'userSocial')" name="userSocial">
            <UserSocial v-model:activeName="activeName" :userInfo="userInfo" />
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-card>
  </PageCard>
</template>

<style scoped lang="scss">
.user {
  max-height: 960px;
  padding: 15px 20px 20px;
}

.card-header {
  display: flex;
  justify-content: center;
  align-items: center;
}

:deep(.el-card .el-card__header, .el-card .el-card__body) {
  padding: 15px !important;
}

.profile-tabs > .el-tabs__content {
  padding: 32px;
  font-weight: 600;
  color: #6b778c;
}

.el-tabs--left .el-tabs__content {
  height: 100%;
}
</style>
